<?php
	if ($_POST)
	{
		require('config.php');
        $originalPass = $_POST['originalPass'];
        $newPass = $_POST['newPass'];
		$originalPass = md5($originalPass);
		$newPass = md5($newPass);
		$stmt = $connection->prepare("update user_id_passwd set md5=? where id=? and md5=?");
		//$stmt = $connection->prepare("update user_id_passwd set md5=?, passwd='hello1234' where id=?");
		$stmt->bind_param("sss", $newPass, $_COOKIE['userid'], $originalPass);
		//$stmt->bind_param("ss", $newPass, $_COOKIE['userid']);
		$stmt->execute();
        if ($stmt->affected_rows == 0)
        {
            echo 'WRONGPASS';
        }
        else
        {
			setcookie("userid", $_COOKIE['userid']); 
			setcookie("usermd5", $newPass);
            echo "true";
        }
    }
	else
	{
		echo "NOPOST";	
	}
?>
